package com.zwan.oam_rtc.utils.messages;

import com.zwan.oam_rtc.utils.wintcp.ByteTransfer;

import java.nio.ByteBuffer;

public class PnPNotifyCallResultMessage extends AbstractStruct {
    private byte[] messageBodyHeader = new byte[8];
    private byte[] callFlowId = new byte[20];
    private byte[] callBackUrl = new byte[300];
    private byte[] recordUrl = new byte[255];
    private byte[] bindId = new byte[4];
    private byte[] callStatus = new byte[4];
    private byte[] strCallingNumber = new byte[29];
    private byte[] strCalledNumber = new byte[29];
    private byte[] callstartTime = new byte[20];
    private byte[] ringTime = new byte[20];
    private byte[] callAnswerTime = new byte[20];
    private byte[] callendTime = new byte[20];
    private byte[] duration = new byte[10];
    private byte[] strCallingDisplay = new byte[30];
    private byte[] strCalledDisplay = new byte[30];
    private byte[] companyid = new byte[4];

    private static int LENGTH = 803;

    /**
     * 返回消息写入buffer
     */
    @Override
    public void writeToBuffer(ByteBuffer bf) {
        bf.put(messageBodyHeader);
        bf.put(callFlowId);
        bf.put(callBackUrl);
        bf.put(recordUrl);
        bf.put(bindId);
        bf.put(callStatus);
        bf.put(strCallingNumber);
        bf.put(strCalledNumber);
        bf.put(callstartTime);
        bf.put(ringTime);
        bf.put(callAnswerTime);
        bf.put(callendTime);
        bf.put(duration);
        bf.put(strCallingDisplay);
        bf.put(strCalledDisplay);
        bf.put(companyid);
    }

    /**
     * buffer读出返回消息
     */
    @Override
    public void readFromBuffer(ByteBuffer bf) {
        bf.get(messageBodyHeader);
        bf.get(callFlowId);
        bf.get(callBackUrl);
        bf.get(recordUrl);
        bf.get(bindId);
        bf.get(callStatus);
        bf.get(strCallingNumber);
        bf.get(strCalledNumber);
        bf.get(callstartTime);
        bf.get(ringTime);
        bf.get(callAnswerTime);
        bf.get(callendTime);
        bf.get(duration);
        bf.get(strCallingDisplay);
        bf.get(strCalledDisplay);
        bf.get(companyid);
    }

    @Override
    public int getLength() {
        return LENGTH;
    }

    public byte[] getMessageBodyHeader() {
        return messageBodyHeader;
    }

    public void setMessageBodyHeader(byte[] messageBodyHeader) {
        this.messageBodyHeader = messageBodyHeader;
    }

    public String getCallFlowId() {
        return ByteTransfer.getString(callFlowId);
    }

    public void setCallFlowId(String callFlowId) {
        ByteTransfer.str2Byte(callFlowId, this.callFlowId);
    }

    public String getCallBackUrl() {
        return ByteTransfer.getString(callBackUrl);
    }

    public void setCallBackUrl(String callBackUrl) {
        ByteTransfer.str2Byte(callBackUrl, this.callBackUrl);
    }


    public String getRecordUrl() {
        return ByteTransfer.getString(recordUrl);
    }

    public void setRecordUrl(String recordUrl) {
        ByteTransfer.str2Byte(recordUrl, this.recordUrl);
    }

    public String getBindId() {
        return ByteTransfer.getString(bindId);
    }

    public void setBindId(String bindId) {
        ByteTransfer.str2Byte(bindId, this.bindId);
    }


    public String getCallStatus() {
        return ByteTransfer.getString(callStatus);
    }

    public void setCallStatus(String callStatus) {
        ByteTransfer.str2Byte(callStatus, this.callStatus);
    }

    public String getStrCallingNumber() {
        return ByteTransfer.getString(strCallingNumber);
    }

    public void setStrCallingNumber(String strCallingNumber) {
        ByteTransfer.str2Byte(strCallingNumber, this.strCallingNumber);
    }


    public String getStrCalledNumber() {
        return ByteTransfer.getString(strCalledNumber);
    }

    public void setStrCalledNumber(String strCalledNumber) {
        ByteTransfer.str2Byte(strCalledNumber, this.strCalledNumber);
    }

    public String getCallstartTime() {
        return ByteTransfer.getString(callstartTime);
    }

    public void setCallstartTime(String callstartTime) {
        ByteTransfer.str2Byte(callstartTime, this.callstartTime);
    }

    public String getRingTime() {
        return ByteTransfer.getString(ringTime);
    }

    public void setRingTime(String ringTime) {
        ByteTransfer.str2Byte(ringTime, this.ringTime);
    }

    public String getCallAnswerTime() {
        return ByteTransfer.getString(callAnswerTime);
    }

    public void setCallAnswerTime(String callAnswerTime) {
        ByteTransfer.str2Byte(callAnswerTime, this.callAnswerTime);
    }

    public String getCallendTime() {
        return ByteTransfer.getString(callendTime);
    }

    public void setCallendTime(String callendTime) {
        ByteTransfer.str2Byte(callendTime, this.callendTime);
    }

    public String getDuration() {
        return ByteTransfer.getString(duration);
    }

    public void setDuration(String duration) {
        ByteTransfer.str2Byte(duration, this.duration);
    }

    public String getStrCallingDisplay() {
        return ByteTransfer.getString(strCallingDisplay);
    }

    public void setStrCallingDisplay(String strCallingDisplay) {
        ByteTransfer.str2Byte(strCallingDisplay, this.strCallingDisplay);
    }

    public String getStrCalledDisplay() {
        return ByteTransfer.getString(strCalledDisplay);
    }

    public void setStrCalledDisplay(String strCalledDisplay) {
        ByteTransfer.str2Byte(strCalledDisplay, this.strCalledDisplay);
    }

    public String getCompanyid() {
        return ByteTransfer.getString(companyid);
    }

    public void setCompanyid(String companyid) {
        ByteTransfer.str2Byte(companyid, this.companyid);
    }

}
